#pragma once

class CCashdrawer
{
public:
    CCashdrawer(int nType, int nPort, int nMBType = -1);
    virtual ~CCashdrawer() {}

    virtual BOOL Initialize();
    virtual int Open() = 0;
    virtual int GetStatus() = 0;

    // zhwang: it is better to create a new parent class named CDevice for all devices, printer, cashdrawer.......
    // include Initialize/GetType/GetLastError methods.
    int GetType() const { return m_nType; }
    int GetLastError() const { return m_nError; }

protected:
    struct ComInfo
    {
        HANDLE hCom;
        int nParity;
        OVERLAPPED oWrite;
        OVERLAPPED oRead;
    };
    ComInfo m_ComInfo;
    int m_nType;
    int m_nPort;
	int m_nMBType;
    int m_nError;
};

class CComCashdrawer : public CCashdrawer
{
public:
    CComCashdrawer(int nPort);
    virtual ~CComCashdrawer();
    
    virtual BOOL Initialize();
    virtual int Open();
    virtual int GetStatus();
};

class CPTCashdrawer: public CCashdrawer
{
public:
    CPTCashdrawer(int nPort);
    virtual ~CPTCashdrawer();

    virtual BOOL Initialize();
    virtual int Open();
    virtual int GetStatus();

private:
    enum EPTPortType
    {
        ECOM,
        ELPT,
        EUSB,
        EUnkown
    };
    EPTPortType m_ePort;
};


class CMBCashdrawer : public CCashdrawer
{
public:
	CMBCashdrawer(int nMBType);
	virtual ~CMBCashdrawer();

	virtual BOOL Initialize();
	virtual int Open();
	virtual int GetStatus();

private:
	BOOL D525_Initialize();
//	BOOL N2600_Initialize();

private:
	unsigned int m_nStatus;
};